package com.qf.mybatisplus.test.pachong;

import org.apache.commons.io.FileUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

public class BossPaChong {

    public static void main(String[] args) throws ClientProtocolException, IOException {

        // 创建httpclient实例
        CloseableHttpClient httpclient = HttpClients.createDefault();

        CloseableHttpResponse response = null;
//        for (int i = 0; i <=10 ; i++) {
            String ss= "https://www.zhipin.com/c101180100-p100101/?page=1&ka=page-1";
            System.out.println(ss);
            HttpGet httpget = new HttpGet(ss);
//        https://pic.netbian.com/e/search/result/index.php?page=2&searchid=2453

            // 执行get请求
            response = httpclient.execute(httpget);
            HttpEntity entity = response.getEntity();
            // 获取返回实体
            String content = EntityUtils.toString(entity, "utf-8");

            // 解析网页 得到文档对象
            Document doc = Jsoup.parse(content);
            // 获取指定的 <img />
//        System.err.println(doc);
            Elements elements = doc.select(".job-list ul li");
        for (Element element : elements) {
            Elements elements1 = element.
                    select(".job-primary .info-primary .primary-wrapper .primary-box .job-title .job-name a");
            String title = elements1.attr("title");
            System.err.println(title);
        }
//            for (int j = 0; j <15 ; j++) {
//                Element element = elements.get(j);
//                Elements elements1 = element.select("a img");
//                String url = elements1.attr("src");
//                // 彼岸图网首页
//                String urlStr = "https://pic.netbian.com";
//                HttpGet picturehttpGet = new HttpGet(url);
//                String s = picturehttpGet+"";
//                String substring = s.substring(4);
//                String[] split = substring.split(" HTTP/1.1");
//                String s1 = String.valueOf(split[0]);
//
//                String string = urlStr+s1;
//                System.out.println(string);
//
//
//
//
//            }


//        }
//        String pre = "https://pic.netbian.com/e/search/result/index.php?page=1&searchid=2453";

        response.close(); // response关闭
        httpclient.close(); // httpClient关闭


    }

}
